#ifndef PROCESSMANAGER_H
#define PROCESSMANAGER_H

#include <vector>
#include <string>
#include <map>
#include <chrono>
#include "processinfo.h"

class ProcessManager {
public:
    ProcessManager();
    virtual ~ProcessManager();
    
    std::vector<ProcessInfo> get_all_processes();
    std::vector<ProcessInfo> get_user_processes();
    std::vector<ProcessInfo> get_system_processes();
    std::vector<ProcessInfo> get_service_processes();
    std::vector<ProcessInfo> get_processes();  // 添加缺失的方法
    void refresh_processes(const std::string& filter_type);  // 添加缺失的方法
    bool terminate_process(int pid);  // 添加缺失的方法
    bool kill_process(int pid);
    bool kill_process_tree(int pid);
    
private:
    std::vector<ProcessInfo> filter_processes(const std::string& filter_type);
    std::vector<ProcessInfo> m_processes;  // 添加进程缓存
    
    // 添加用于计算速率的数据结构
    struct ProcessSample {
        unsigned long utime;
        unsigned long stime;
        unsigned long long read_bytes;
        unsigned long long write_bytes;
        std::chrono::steady_clock::time_point timestamp;
    };
    
    std::map<int, ProcessSample> m_process_samples;
    std::chrono::steady_clock::time_point m_last_update;
};

#endif // PROCESSMANAGER_H